<template>
  <div ref="dlclt" id="dlclt">
    <div class="app-container">
    <div ref="probox" class="probox">
      <div class="left">
        <div class="leftItem">
          <img class="hjf" src="@/assets/clfb/hjf.png" alt="" />
          <span class="text"> 35KVⅠ回进线</span>
          <img class="hjf" src="@/assets/clfb/hjf.png" alt="" />

          <img
            v-if="dataObjCur.z16387 == 'blue'"
            class="lefttop"
            src="@/assets/clfb/lefttop.gif"
            alt=""
          />
          <img
            v-else-if="dataObjCur.z16387 == 'yellow'"
            class="lefttop"
            src="@/assets/clfb/lefttop2.png"
            alt=""
          />
          <img v-else class="lefttop" src="@/assets/clfb/lefttop1.png" alt="" />
          <div class="list">
            <div class="list_item">
              <div>
                <p>Uab:</p>
                <p style="color: #2e81ff">{{ dataObj.OneUab }}kV</p>
              </div>
              <div>
                <p>Ua:</p>
                <p style="color: #2e81ff">{{ dataObj.OneUa }}kV</p>
              </div>
              <div>
                <p>la:</p>
                <p style="color: #2e81ff">{{ dataObj.Onela }}A</p>
              </div>
            </div>
            <div class="list_item">
              <div>
                <p>Ubc:</p>
                <p style="color: #2e81ff">{{ dataObj.OneUbc }}kV</p>
              </div>
              <div>
                <p>Ub:</p>
                <p style="color: #2e81ff">{{ dataObj.OneUb }}kV</p>
              </div>
              <div>
                <p>lb:</p>
                <p style="color: #2e81ff">{{ dataObj.Onelb }}A</p>
              </div>
            </div>
            <div class="list_item">
              <div>
                <p>Uca:</p>
                <p style="color: #2e81ff">{{ dataObj.OneUca }}kV</p>
              </div>
              <div>
                <p>Uc:</p>
                <p style="color: #2e81ff">{{ dataObj.OneUc }}kV</p>
              </div>
              <div>
                <p>lc:</p>
                <p style="color: #2e81ff">{{ dataObj.Onelc }}A</p>
              </div>
            </div>
          </div>
        </div>
        <div class="leftItem">
          <img class="hjf" src="@/assets/clfb/hjf.png" alt="" />
          <span class="text"> 35KVⅡ回进线</span>
          <img class="hjf" src="@/assets/clfb/hjf.png" alt="" />
          <img
            v-if="dataObjCur.z16428 == 'blue'"
            class="lefttop"
            src="@/assets/clfb/mid.gif"
            alt=""
          />
          <img
            v-else-if="dataObjCur.z16428 == 'yellow'"
            class="lefttop"
            src="@/assets/clfb/mid2.png"
            alt=""
          />
          <img v-else class="lefttop" src="@/assets/clfb/mid1.png" alt="" />
          <div class="list2">
            <div class="list_item">
              <div>
                <p>Uab:</p>
                <p style="color: #2e81ff">{{ dataObj.TwoUab }}kV</p>
              </div>
              <div>
                <p>Ua:</p>
                <p style="color: #2e81ff">{{ dataObj.TwoUa }}kV</p>
              </div>
              <div>
                <p>la:</p>
                <p style="color: #2e81ff">{{ dataObj.Twola }}A</p>
              </div>
            </div>
            <div class="list_item">
              <div>
                <p>Ubc:</p>
                <p style="color: #2e81ff">{{ dataObj.TwoUbc }}kV</p>
              </div>
              <div>
                <p>Ub:</p>
                <p style="color: #2e81ff">{{ dataObj.TwoUb }}kV</p>
              </div>
              <div>
                <p>lb:</p>
                <p style="color: #2e81ff">{{ dataObj.Twolb }}A</p>
              </div>
            </div>
            <div class="list_item">
              <div>
                <p>Uca:</p>
                <p style="color: #2e81ff">{{ dataObj.TwoUca }}kV</p>
              </div>
              <div>
                <p>Uc:</p>
                <p style="color: #2e81ff">{{ dataObj.TwoUc }}kV</p>
              </div>
              <div>
                <p>lc:</p>
                <p style="color: #2e81ff">{{ dataObj.Twolc }}A</p>
              </div>
            </div>
          </div>
        </div>
        <div class="leftItem">
          <img class="hjf" src="@/assets/clfb/hjf.png" alt="" />
          <span class="text"> 35KVⅢ回进线</span>
          <img class="hjf" src="@/assets/clfb/hjf.png" alt="" />
          <div class="list3">
            <div class="list_item">
              <div>
                <p>Uab:</p>
                <p style="color: #2e81ff">{{ dataObj.ThirdUab }}kV</p>
              </div>
              <div>
                <p>Ua:</p>
                <p style="color: #2e81ff">{{ dataObj.ThirdUa }}kV</p>
              </div>
              <div>
                <p>la:</p>
                <p style="color: #2e81ff">{{ dataObj.Thirdla }}A</p>
              </div>
            </div>
            <div class="list_item">
              <div>
                <p>Ubc:</p>
                <p style="color: #2e81ff">{{ dataObj.ThirdUbc }}kV</p>
              </div>
              <div>
                <p>Ub:</p>
                <p style="color: #2e81ff">{{ dataObj.ThirdUb }}kV</p>
              </div>
              <div>
                <p>lb:</p>
                <p style="color: #2e81ff">{{ dataObj.Thirdlb }}A</p>
              </div>
            </div>
            <div class="list_item">
              <div>
                <p>Uca:</p>
                <p style="color: #2e81ff">{{ dataObj.ThirdUca }}kV</p>
              </div>
              <div>
                <p>Uc:</p>
                <p style="color: #2e81ff">{{ dataObj.ThirdUc }}kV</p>
              </div>
              <div>
                <p>lc:</p>
                <p style="color: #2e81ff">{{ dataObj.Thirdlc }}A</p>
              </div>
            </div>
          </div>
          <img
            class="lefttop leftbottom"
            v-if="dataObjCur.z16463 == 'blue'"
            src="@/assets/clfb/leftbottom.gif"
            alt=""
          />
          <img
            class="lefttop leftbottom"
            v-else-if="dataObjCur.z16463 == 'yellow'"
            src="@/assets/clfb/leftbottom2.png"
            alt=""
          />
          <img
            v-else
            class="lefttop leftbottom"
            src="@/assets/clfb/leftbottom1.png"
            alt=""
          />
        </div>
      </div>
      <div class="mid">
        <div class="rightimgbox">
          <ul class="rightlist">
            <li>
              <p>Uab:</p>
              <p class="textcolor">{{ dataObj.jiaUab }}V</p>
            </li>
            <li>
              <p>la:</p>
              <p class="textcolor">{{ dataObj.jiala }}A</p>
            </li>
            <li>
              <p>P:</p>
              <p class="textcolor">{{ dataObj.jiaP }}KW</p>
            </li>
          </ul>
          <ul class="rightlist rightlist1">
            <li>
              <p>Uab:</p>
              <p class="textcolor">{{ dataObj.yiUab }}V</p>
            </li>
            <li>
              <p>la:</p>
              <p class="textcolor">{{ dataObj.yila }}A</p>
            </li>
            <li>
              <p>P:</p>
              <p class="textcolor">{{ dataObj.yiP }}KW</p>
            </li>
          </ul>
          <ul class="rightlist rightlist2">
            <li>
              <p>Uab:</p>
              <p class="textcolor">{{ dataObj.bingUab }}V</p>
            </li>
            <li>
              <p>la:</p>
              <p class="textcolor">{{ dataObj.bingla }}A</p>
            </li>
            <li>
              <p>P:</p>
              <p class="textcolor">{{ dataObj.bingP }}KW</p>
            </li>
          </ul>
          <ul class="rightlist rightlist3">
            <li>
              <p>Uab:</p>
              <p class="textcolor">{{ dataObj.dingUab }}V</p>
            </li>
            <li>
              <p>la:</p>
              <p class="textcolor">{{ dataObj.dingla }}A</p>
            </li>
            <li>
              <p>P:</p>
              <p class="textcolor">{{ dataObj.dingP }}KW</p>
            </li>
          </ul>
          <ul class="rightlist rightlist4">
            <li>
              <p>Uab:</p>
              <p class="textcolor">{{ dataObj.wuUab }}V</p>
            </li>
            <li>
              <p>la:</p>
              <p class="textcolor">{{ dataObj.wula }}A</p>
            </li>
            <li>
              <p>P:</p>
              <p class="textcolor">{{ dataObj.wuP }}KW</p>
            </li>
          </ul>
          <!-- <ul class="rightlist rightlist5">
          <li><p>Uab:</p> <p class="textcolor">{{dataObj.jiechuanUab}}kv</p></li>
          <li><p>la:</p> <p class="textcolor">{{dataObj.jiechuanla}}A</p></li>
          <li><p>P:</p> <p class="textcolor">{{dataObj.jiechuanP}}KW</p></li>
        </ul>
        <ul class="rightlist rightlist6">
          <li><p>Uab:</p> <p class="textcolor">{{dataObj.xingzhengUab}}kv</p></li>
          <li><p>la:</p> <p class="textcolor">{{dataObj.xingzhengla}}A</p></li>
          <li><p>P:</p> <p class="textcolor">{{dataObj.xingzhengP}}KW</p></li>
        </ul> -->
          <ul class="rightlist rightlist7">
            <li>
              <p>Uab:</p>
              <p class="textcolor">{{ dataObj.xiaofangUab }}V</p>
            </li>
            <li>
              <p>la:</p>
              <p class="textcolor">{{ dataObj.xiaofangla }}A</p>
            </li>
            <li>
              <p>P:</p>
              <p class="textcolor">{{ dataObj.xiaofangP }}KW</p>
            </li>
          </ul>

          <img class="rightimg" src="@/assets/clfb/right.gif" alt="" />
        </div>

        <div class="mid_top">
          <img src="@/assets/clfb/tuceng.png" alt="" />
        </div>
        <div class="mid_bottom">
          <div class="chaoliu">
            <h3>潮流参数</h3>
            <div class="cllist">
              <ul>
                <li class="colortext">{{ chaoliu.chaoliucanshu }}%RH</li>
                <li>实时有功</li>
              </ul>
              <div class="line"></div>
              <ul>
                <li class="colortext">{{ chaoliu.shishiwugong }}%RH</li>
                <li>实时无功</li>
              </ul>
              <div class="line"></div>
              <ul>
                <li class="colortext">{{ chaoliu.gonglvyinshu }}</li>
                <li>功率因数</li>
              </ul>
              <div class="line"></div>
              <ul>
                <li class="colortext">
                  {{ chaoliu.jinriyongdian | decimalplaces }}kWh
                </li>
                <li>今日用电量</li>
              </ul>
              <div class="line"></div>
              <ul>
                <li class="colortext">
                  {{ chaoliu.quanyueyongdian | decimalplaces }}kWh
                </li>
                <li>本月用电量</li>
              </ul>
            </div>
          </div>
          <div class="chaoliu2">
            <div class="rongliang">
              <h3>1#</h3>
              <div class="rongliang_list">
                <ul>
                  <li class="colortext1">12500kwA</li>
                  <li>主变容量</li>
                </ul>
                <ul>
                  <li style="margin-bottom: 10px">
                    <span class="colortext"
                      >{{
                        yongdain["1#在用容量"] && yongdain["1#在用容量"]
                      }}kwA</span
                    >
                    <span class="colortext"
                      >{{ yongdain["1#百分比"] | percentage }}%</span
                    >
                  </li>
                  <li>在用容量</li>
                </ul>
              </div>
            </div>
            <!-- <div class="line"></div> -->
            <div class="rongliang">
              <h3>2#</h3>
              <div class="rongliang_list">
                <ul>
                  <li class="colortext1">12500kwA</li>
                  <li>主变容量</li>
                </ul>
                <ul>
                  <li style="margin-bottom: 10px">
                    <span class="colortext"
                      >{{
                        yongdain["2#在用容量"] && yongdain["2#在用容量"]
                      }}kwA</span
                    >
                    <span class="colortext"
                      >{{ yongdain["2#百分比"] | percentage }}%</span
                    >
                  </li>
                  <li>在用容量</li>
                </ul>
              </div>
            </div>
          </div>
        </div>
      </div>
      <div class="right">
        <div class="buttons">
          <el-button
            @click="() => (type = 1)"
            :type="type == 1 ? 'success' : 'info'"
            >今日累计</el-button
          >
          <el-button
            @click="() => (type = 0)"
            :type="type == 0 ? 'success' : 'info'"
            >本月累计</el-button
          >
        </div>
        <div v-for="item in trDay" :key="item.key" class="right_item">
          <div class="item_left">
            <img :src="item.image" alt="" />
            <p>{{ item.title }}</p>
          </div>
          <div class="item_right">
            总用电量：<span style="color: #2e81ff">
              {{ dataObj[type == 1 ? item.key : item.key1] || 0 }} kWh</span
            >
          </div>
        </div>
      </div>
    </div>
    </div>
  </div>
</template>

<script>
export default {
  data() {
    return {
      path: "ws://10.2.40.179:7071/fzodb/websocket/111",
      // path: "ws://10.2.39.205:9991/sfodb/websocket/111",
      type: 1,
      trDay: [
        {
          title: "甲机房",
          key: "jiaDay",
          key1: "jiaMonth",
          image: require("@/assets/clfb/jifang.png"),
        },
        {
          title: "乙机房",
          key: "yiDay",
          key1: "yiMonth",
          image: require("@/assets/clfb/jifang.png"),
        },
        {
          title: "丙机房",
          key: "bingDay",
          key1: "bingMonth",
          image: require("@/assets/clfb/jifang.png"),
        },
        {
          title: "丁机房",
          key: "dingDay",
          key1: "dingMonth",
          image: require("@/assets/clfb/jifang.png"),
        },
        {
          title: "戊机房",
          key1: "wuMonth",
          key: "wuDay",
          image: require("@/assets/clfb/jifang.png"),
        },
        {
          title: "中控机房",
          key1: "jiechuanMonth",
          key: "jiechuanDay",
          image: require("@/assets/clfb/jifang.png"),
        },
        {
          title: "行政机房",
          key1: "xingzhengMonth",
          key: "xingzhengDay",
          image: require("@/assets/clfb/jifang.png"),
        },
        {
          title: "消防用电",
          key: "xiaofangDay",
          key1: "xiaofangMonth",
          image: require("@/assets/clfb/jifang.png"),
        },
      ],
      dataObj: {
          OneUab:'1234',
          OneUa:'1234',
          Onela:'1234',
          OneUbc:'1234',
          OneUb:'1234',
          Onelb:'1234',
          OneUca:'0.2',
          OneUc:'0.5',
          Onelc:'0.45',
          TwoUab:'1234',
          TwoUa:'1234',
          Twola:'1234',
          TwoUbc:'1234',
          TwoUb:'1234',
          Twolb:'1234',
          ThirdUab:'1234',
          ThirdUa:'1234',
          Thirdla:'1234',
          ThirdUbc:'1234',
          ThirdUb:'1234',
          Thirdlb:'1234',
          ThirdUca:'0.15',
          ThirdUc:'0.14',
          Thirdlc:'0.12',
          jiaUab:'1234kw',
          jiala:'1234kw',
          jiaP:'1234kw',
          yiUab:'1234kw',
          yila:'1234kw',
          yiP:'1234kw',
          bingUab:'1234kw',
          bingla:'1234kw',
          bingP:'1234kw',
          dingUab:'1234kw',
          dingla:'1234kw',
          dingP:'1234kw',
          wuUab:'1234kw',
          wula:'1234kw',
          wuP:'1234kw',
          xiaofangUab:'1234kw',
          xiaofangla:'1234kw',
          xiaofangP:'1234kw',
          jiaDay:'6780',
          yiDay:'8780',
          bingDay:'5792',
          dingDay:'6780',
          wuDay:'6780',
          jiaDay:'6780',
          jiechuanDay:'7789',
          xingzhengDay:'8888',
          xiaofangDay:'9999',
          jiaMonth:'6780424',
          yiMonth:'878024',
          bingMonth:'579224',
          dingMonth:'678024',
          wuMonth:'678024',
          jiaMonth:'6780342',
          jiechuanMonth:'778943',
          xingzhengMonth:'888833',
          xiaofangMonth:'999987'
      },
      chaoliu: {
          chaoliucanshu:'24',
          shishiwugong:'36',
          gonglvyinshu:'34',
          jinriyongdian:'34',
          quanyueyongdian:'12',


      },
      yongdain: {
          '1#在用容量':'3150',
          '1#百分比':'0.5',
          '2#百分比':'0.5',
          '2#在用容量':'3150',
      },
      dataObjCur:{},
    };
  },
  mounted() {
    this.init();
    window.onresize = () => {};
  },
  filters: {
    percentage(val) {
      if (!val) return 0;
      return Number(val * 100).toFixed(1);
    },
    decimalplaces(val) {
      if (!val) return 0;
      return Number(val).toFixed(1);
    },
  },
  methods: {
    init: function () {
      // if (typeof WebSocket === "undefined") {
      //   alert("您的浏览器不支持socket");
      // } else {
      //   // 实例化socket
      //   this.socket = new WebSocket(this.path);
      //   // 监听socket连接
      //   this.socket.onopen = this.open;
      //   // 监听socket错误信息
      //   this.socket.onerror = this.error;
      //   // 监听socket消息
      //   this.socket.onmessage = this.getMessage;
      // }
    },
    open: function () {
      // console.log("socket连接成功");
    },
    error: function () {
      // console.log("连接错误");
    },
    getMessage: function (msg) {
      let dataObj = eval("(" + msg.data + ")");
      if (dataObj.msgType == "dianlichaoliu") {
        this.dataObj = dataObj;
        this.chaoliu = this.dataObj["潮流参数"];
        this.yongdain = this.dataObj["1#2#"];
      }
      if (this.dataObj.msgType == "yijifangpower") {
          this.dataObjCur = this.dataObj;
      }
    },
    send: function () {
      this.socket.send(params);
    },
    close: function () {
      // console.log("socket已经关闭");
    },
  },
};
</script>

<style lang="scss" scoped>
#dlclt {
  /*width: 100%;*/
  /*height: 100%;*/
  /*background: rgb(244, 243, 249);*/
  /*box-sizing: border-box;*/
  /*overflow: auto;*/
  min-height: calc(100vh - 84px);
  width: 100%;
  position: relative;
  overflow: hidden;
  background: url("../../../assets/showImages/dataVivew/backdrop.png") 0 0
  no-repeat;
  background-size:cover;
  &::-webkit-scrollbar {
    display: none; /* Chrome Safari */
  }

  .probox {
    min-width: 100%;
    // min-height: 973px;
    // margin: 50px auto;
    margin-top:50px;
    box-sizing: border-box;

    position: relative;
    width: 100%;
    height: 760px;

    display: flex;
    justify-content: space-between;
  }
  .left{
    width:15%;
  }
  .leftItem {
    width: 100%;
    height: 150px;
    background: #ffffff;
    box-shadow: 0px 1px 6px 0px rgba(170, 182, 211, 0.35);
    border-radius: 5px;
    margin-top: 110px;
    margin-left: 40px;
    position: relative;
    .list,
    .list2,
    .list3 {
      left: 105%;
      top: -75px;
      padding: 10px;
      position: absolute;
      width: 65%;
      z-index:4;
      height: 160px;
      background: #ffffff;
      box-shadow: 0px 1px 6px 0px rgba(170, 182, 211, 0.35);
      border-radius: 5px;
      display: flex;
      flex-direction: column;
      .list_item {
        flex: 1;

        display: flex;
        font-size: 12px;

        div {
          margin: 5px;
          border-bottom: 1px solid #e1e1e1;
          flex: 1;
        }
      }
    }
    .list{
      height:240px,
    }
    .list2 {
      left: 105%;
      top: -80px;
    }
    .list3 {
      left: 105%;
      top: -170px;
      height:240px,
    }
    .text {
      position: absolute;
      bottom: 10px;
      right: 10px;

      font-size: 16px;
      font-family: PingFang SC;
      font-weight: 400;
      color: #1e1e1e;
    }
    .hjf {
      position: absolute;
      width: 217px;
      height: 166px;
      left: 50%;
      transform: translateX(-50%);
      top: -87px;
    }
    .lefttop {
      // width: 300px;
      width:100%;
      position: absolute;
      top: 50%;
      left: 100%;
      z-index:2
    }
    .leftbottom {
      top: -34px;

      left: 100%;
    }
  }
  .mid {
    padding: 20px;
    position: absolute;
    top: 50%;
    left: 49%;
    transform: translate(-50%, -50%);
    width: 34%;
    height: 480px;
    background: #ffffff;
    box-shadow: 0px 1px 6px 0px rgba(170, 182, 211, 0.35);
    border-radius: 5px;
    z-index:3;
    .rightimgbox {
      position: relative;
      width: 52%;
      height: 707px;
      top: -92px;
      position: absolute;
      left: 100%;
      .rightlist {
        .textcolor {
          color: #2e81ff;
        }
        padding: 5px;
        font-size: 12px;
        border-radius: 2px;
        display: flex;
        justify-content: center;
        align-items: center;
        height: 56px;
        width: 200px;
        background: #ffffff;
        position: absolute;
        top: -64px;
        left: 19%;
        li {
          width: 110px;
        }
      }
      .rightimg {
        width: 90%;
        height: 100%;
      }
      .rightlist1 {
        top: 41px;
      }
      .rightlist2 {
        top: 135px;
      }
      .rightlist3 {
        top: 241px;
      }
      .rightlist4 {
        top: 340px;
      }
      .rightlist5 {
        top: 470px;
      }
      .rightlist6 {
        top: 565px;
      }
      .rightlist7 {
        top: 630px;
      }
    }

    .mid_top {
      position: relative;
      width: 100%;
      height: 40%;

      img {
        width: 510px;
        height: 339px;
        position: absolute;
        left: 50%;
        transform: translate(-50%, -60%);
      }
    }
    .mid_bottom {
      width: 100%;
      height: 60%;
      position: relative;

      .cllist {
        display: flex;
        justify-content: space-around;
        text-align: center;
        border-bottom: 1px solid #e1e1e1;
        height: 92px;
      }
      .line {
        width: 1px;
        height: 35px;
        margin-top: 10px;
        background: #e1e1e1;
      }
      .colortext,
      .colortext1 {
        font-size: 20px;
        font-family: PingFang SC;
        font-weight: 400;
        color: #2e81ff;
        line-height: 24px;
        margin-bottom: 10px;
      }
      .colortext1 {
        color: #000;
      }
      .chaoliu2 {
        display: flex;
        .rongliang {
          flex: 1;
          .rongliang_list {
            text-align: center;
            display: flex;

            ul {
              margin-right: 20px;
            }
          }
        }
      }
    }
  }
  .right {
    width: 6%;
    margin-right: 12%;
    position: relative;
    .buttons {
      position: fixed;
      width: 300px;
      top: 120px;
      right: 0px;
      z-index: 999;
      transform: translateY(-100%);
    }
    .right_item {
      /*padding: 20px 0;*/
      width: 282px;
      display: flex;
      height: 80px;
      margin-top: 17px;
      box-sizing: content-box;
      background: #ffffff;
      align-items: center;
      .item_left {
        margin-right: 5px;
        text-align: center;
        width: 80px;
        height: 60px;
        border-right: 1px solid #525151;
        img {
          width: 20px;
          height: 20px;
        }
      }
    }
  }
}
  .app-container{
    overflow: hidden;
  }
</style>
